# 作业：
# 1、搜索：南京市，点击出来的南京市——》点击搜索——》看是否有跳转到南京市民俗地区
# 4、背下adb命令和monkey命令，背三种等待方式的区别
# 做三条case的书写同时，要用到三种等待，多种定位方式，加上fixture夹具，合理的setup和teardown，最终结果生成allure报告
# 失败结果需要有截图留存
# from appium import webdriver
# from appium.webdriver.common.mobileby import MobileBy  # 移动端的操作
# from appium.webdriver.common.touch_action import TouchAction  # 操作滑动的
# import time
# import pytest
# from selenium.webdriver.support import expected_conditions
# from selenium.webdriver.support.ui import WebDriverWait
#
# class TestYJMS():
#     @pytest.fixture(scope='function', autouse=True)
#     def setup_model(self):
#         dic = {
#             "appPackage": "me.onehome.app",
#             "appActivity": ".activity.ActivitySplash_",
#             "deviceName": "d2q",
#             "platformName": "Android",
#             "platformVersion": "7.1.2"
#         }
#         self.driver = webdriver.Remote("http://localhost:4723/wd/hub", dic)
#         self.driver.implicitly_wait(15)  # 设置一个全局的等待,隐式等待
#         # 点击出现的同意按钮
#         button = self.driver.find_element(MobileBy.ID, "me.onehome.app:id/tv_agree")
#         button.click()  # 点击同意按钮
#         # 滑动引导页面
#         TouchAction(self.driver).press(x=600, y=975).move_to(x=12, y=975).release().perform()  # 滑动第一次
#         TouchAction(self.driver).press(x=600, y=975).move_to(x=12, y=975).release().perform()  # 滑动第二次
#         TouchAction(self.driver).press(x=600, y=975).move_to(x=12, y=975).release().perform()  # 滑动第三次
#         # 通过tap点击立即开启按钮
#         TouchAction(self.driver).tap(x=207, y=1429).perform()
#         yield
#         self.driver.quit()  # 每条用例执行完退出
#
#     def test_search(self):
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/ll_title").click()
#         input_text = self.driver.find_element(MobileBy.ID,"me.onehome.app:id/editText")
#         input_text.clear()
#         input_text.send_keys("南京市")
#         time.sleep(2)
#         TouchAction(self.driver).tap(x=207,y=207).perform()
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/doSearch")
#         title = WebDriverWait(self.driver,10).until(expected_conditions.presence_of_all_elements_located((MobileBy.CLASS_NAME,"android.widget.TextView")))[0]
#         text = title.text
#         try:
#             assert  text =="南京市"
#         except:
#             self.driver.get_screenshot_as_file("text.png")
#             raise "用例执行失败"

# 2、点击：东京都->更多按钮——》获取第一个民宿的标题、价格——》看是否内容正确
# from appium import webdriver
# from appium.webdriver.common.mobileby import MobileBy
# from appium.webdriver.common.touch_action import TouchAction
# import time
# import pytest
# from selenium.webdriver.support import expected_conditions
# from selenium.webdriver.support.ui import WebDriverWait
#
#
# class TestYJMS():
#     @pytest.fixture(scope='function', autouse=True)
#     def setuo_model(self):
#         dic = {
#             "appPackage": "me.onehome.app",
#             "appActivity": ".activity.ActivitySplash_",
#             "deviceName": "d2q",
#             "platformName": "Android",
#             "platformVersion": "7.1.2"
#         }
#         self.driver = webdriver.Remote("http://localhost:4723/wd/hub", dic)
#         self.driver.implicitly_wait(15)
#         button = self.driver.find_element(MobileBy.ID, "me.onehome.app:id/tv_agree")
#         button.click()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).tap(x=207, y=1429).perform()
#         yield
#         self.driver.quit()
#
#     def test_search(self):
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/rightIcon").click()
#         title = WebDriverWait(self.driver, 10).until(
#             expected_conditions.presence_of_all_elements_located((MobileBy.CLASS_NAME, "android.widget.TextView")))[
#             1]
#         test = title.text
#         title1 = WebDriverWait(self.driver, 10).until(
#             expected_conditions.presence_of_all_elements_located((MobileBy.CLASS_NAME, "android.widget.TextView")))[7]
#         text1 = title1.text
#         try:
#             assert test == "【合法民宿】西新宿站徒步4分钟/1站地铁直达新宿/免费Wi-Fi* one-704"
#             assert text1 == "948"
#             return f"第一个民宿标题为{test}", f"价格为{text1}"
#         except:
#             self.driver.get_screenshot_as_file("text.png")
#             raise "用例执行失败"
# 3、点击：最下面我的——》点击民宿订单——》点击密码登录——》输入手机号、密码——》点击登录
# from appium import webdriver
# from appium.webdriver.common.mobileby import MobileBy
# from appium.webdriver.common.touch_action import TouchAction
# import time
# import pytest
# from selenium.webdriver.support import expected_conditions
# from selenium.webdriver.support.ui import WebDriverWait
#
#
# class TestYJMS():
#     @pytest.fixture(scope='function', autouse=True)
#     def setuo_model(self):
#         dic = {
#             "appPackage": "me.onehome.app",
#             "appActivity": ".activity.ActivitySplash_",
#             "deviceName": "d2q",
#             "platformName": "Android",
#             "platformVersion": "7.1.2"
#         }
#         self.driver = webdriver.Remote("http://localhost:4723/wd/hub", dic)
#         self.driver.implicitly_wait(30)
#         button = self.driver.find_element(MobileBy.ID, "me.onehome.app:id/tv_agree")
#         button.click()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).press(x=700, y=900).move_to(x=1, y=900).release().perform()
#         TouchAction(self.driver).tap(x=207, y=1429).perform()
#         yield
#         self.driver.quit()
#     def test_search(self):
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/tv_guid3").click()
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/ll_my_trip_manage").click()
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/rb_pw_login").click()
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/et_login_number").click()
#         self.driver.find_element(MobileBy.ID,"me.onehome.app:id/et_login_number").click()
#         input_text = self.driver.find_element(MobileBy.ID,"	me.onehome.app:id/et_login_number")
#         input_text.clear()
#         input_text.send_keys("15124139366")
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID, "me.onehome.app: id / et_login_password").click()
#         input_text1 = self.driver.find_element(MobileBy.ID,"me.onehome.app: id / et_login_password")
#         input_text1.clear()
#         input_text1.send_keys("zz3235154")
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID, "me.onehome.app:id/cb_privacy").click()
#         time.sleep(2)
#         self.driver.find_element(MobileBy.ID, "me.onehome.app:id/bt_fulfill").click()
















































































